<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../../back-common.jsp"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<% Long offset = 1L;%>

<form:form  action="${contextPath}/admin/member/user/roles" id="form1" method="post">
	   <input type="hidden" id="appNo" name="appNo" value="${param.appNo}">
		<input type="hidden" name="userId" value="${bean.id }"> 
        <table class="${tableclass}" style="width: 100%">
		    <thead>
		    	<tr><th><strong class="am-text-primary am-text-lg">权限管理</strong> /  用户[${bean.name }]角色列表 </th></tr>
		    </thead>
	    </table>
		
	 <div align="center">
         <%@ include file="/WEB-INF/pages/common/messages.jsp"%>
        
	    <display:table name="list" id="item" export="false" class="${tableclass}" style="width:100%">
		      <display:column style="width:70px" title="<input type='checkbox'  id='checkbox' name='checkbox' onClick='javascript:selAll()' /><span>顺序</span>">
				   <input type="checkbox" name="strArray" value="${item.id}" /><%=offset++%>
			  </display:column>
		      <display:column title="名称 " property="name" ></display:column>
		      <display:column title="角色名称 " property="roleType"></display:column>
		      <display:column title="状态">
		      		<ls:optionGroup type="label" required="true" cache="true" beanName="ENABLED" selectedValue="${item.enabled}" defaultDisp=""/>
		      </display:column>
		      <display:column title="备注" property="note"></display:column>
	    </display:table>
     </div>
		
	<div align="center">
		<input class="${btnclass}" type="button" value="增加角色" onclick="window.location='<ls:url address="/admin/member/user/otherRoles/${bean.id}?appNo=${appNo}"/>'"/>&nbsp;
		<input class="${btnclass}" type="button" value="删除" onclick="deleteAction();"/>&nbsp;
		<input class="${btnclass}" type="button" value="返回"  onclick="javascript:history.go(-1);" />
	</div>
</form:form>

<script language="JavaScript" type="text/javascript">
  function confirmDelete(){
	 return con = confirm("确定要删除吗？");
  }

  //全选
  function selAll(){
    chk = document.getElementById("checkbox");
	allSel = document.getElementsByName("strArray");
	
	if(!chk.checked){
		for(i=0;i<allSel.length;i++){
			  allSel[i].checked=false;
		}
	}else{
		for(i=0;i<allSel.length;i++){
			  allSel[i].checked=true;
		}
	}
}
	
 function deleteAction(){
	//获取选择的记录集合
	selAry = document.getElementsByName("strArray");
	count = 0;
	selValue = "";
	for(i = 0; i < selAry.length; i++){
		if(selAry[i].checked){
			count++;
			selValue = selAry[i].value;
		}
	}
	
	if(count<1){
		art.dialog.alert("删除时至少选中一条记录！");
		return false;
	}
	
	if(confirmDelete()){
	    document.forms[0].action="${contextPath}/admin/member/user/deleteUserRoleByUserId";  
	    document.forms[0].submit(); 
	    return true ;
    }else{
       return false ;
    } 
	    
}
	
</script>
